using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Globalization;
using System.Security.Principal;

namespace Safira.Tools.Sharepoint.Spome
{
    public class WebConnector
    {
        public static SPWeb Connect(string url)
        {
            SPWeb web;
            WindowsIdentity myIdentity = WindowsIdentity.GetCurrent();

            try
            {
                using (SPSite site = new SPSite(url))
                {
                    web = site.OpenWeb();
                }
            }
            catch (Exception e)
            {
                throw new Exception(string.Format(CultureInfo.InvariantCulture,"<Message>{0}</Message>\n<Trace>{1}</Trace>\n<Identity>{2}</Identity>\n", e.Message, e.StackTrace, myIdentity.ToString()));
            }

            return web;
        }
    }
}
